<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>点击</button>
<div></div>
<script>
    var btn = document.querySelector('button');
    var div = document.querySelector('div');
    var timer = 5;
    btn.addEventListener('click', function () {
        // console.log(window.location.href);
        location.href = 'http://www.itcast.cn';
    })
    setInterval(function () {
        if (timer == 0) {
            location.href = 'http://www.itcast.cn';
        } else {
            div.innerHTML = '您将在' + timer + '秒钟之后跳转到首页'
            timer--;
        }
    }, 1000)
</script>
</body>
</html>